-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any asset fee feature #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, but a few minor changes needed.
void ClearPrioritisation(const uint256& hash); | ||
|
||
/** Recompute valuation of all transaction fees, called whenever exchange rates have been updated. */ | ||
void RecomputeFees(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need that EXCLUSIVE_LOCKS_REQUIRED here? Why or why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RecomputeFees()
takes the lock, and EXCLUSIVE_LOCKS_REQUIRED
means that the lock must already be held. So we don't need it here.
|
||
CAsset feeAsset; | ||
if (g_con_any_asset_fees) { | ||
feeAsset = fee_map.begin()->first; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there's zero, or two or more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, at least explain it in a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment and some TODOs in: 65ffeb0
The short answer is that there should never be more than one, and since ConstructTransaction
enforces this, it's loosely correct by construction. If we want a stronger guarantee, we might want to add a check in consensus.
self.node1_nonct_address = self.nodes[1].getaddressinfo(self.node1_address)["unconfidential"] | ||
|
||
self.nodes[0].setfeeexchangerates({ "gasset": 100000000, self.asset: 100000000 }) | ||
self.nodes[1].setfeeexchangerates({ "gasset": 100000000, self.asset: 100000000 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include test of getfeeexchangerates
} | ||
EnsureAnyMemPool(request.context).RecomputeFees(); | ||
return NullUniValue; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this is good enough for now, but then open a followup issue so that:
- the load-from-file and load-from-rpc share the same code
- that code validates the entire data structure before it is used, so the global exchangeRateMap is not left in unusable state if something goes wrong.
- maybe save the json to a temporary file, fdatasync, then atomically replace the startup file, if things go right.
This covers the first milestone of the No Coin project, modifying the on-chain protocol to support fee payment in any asset. It also includes the necessary changes to the mempool to allow block signers to valuate assets at their desired exchange rates, and introduces two new exchangerate RPCs for getting and setting those rates.
Cliff notes:
g_con_any_asset_fees
for enabling No Coin featurecreaterawtransaction
,fundrawtransaction
, andsendtoaddress
)getfeeexchangerates
andsetfeeexchangerates
)gettransaction
andlisttransactions
)